package com.example.demo.mapper;

import com.example.demo.entity.AfoneshopTopic;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.*;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 主题精选 Mapper 接口
 * </p>
 *
 * @author Mr.We
 * @since 2024-06-22
 */
@Mapper
public interface AfoneshopTopicMapper extends BaseMapper<AfoneshopTopic> {
    @Select("select * from AFoneshop_topic where id = #{value}")
    AfoneshopTopic queryObject(@Param("value") Integer id);

    @Select("<script>" +
            "select" +
            "        <if test='fields != null and fields !=\"\"'>" +
            "            ${fields}" +
            "        </if>" +
            "        <if test='fields == null or fields == \"\"'>" +
            "            *" +
            "        </if>" +
            "        from AFoneshop_topic" +
            "        <choose>" +
            "            <when test='sidx != null and sidx.trim() != null' >" +
            "                order by ${sidx} ${order}" +
            "            </when>" +
            "            <otherwise>" +
            "                order by id desc" +
            "            </otherwise>" +
            "        </choose>" +
            "        <if test='offset != null and limit != null' >" +
            "            limit #{offset}, #{limit}" +
            "        </if>" +
            "</script>")
    List<AfoneshopTopic> queryList(Map<String, Object> map);

    @Select("select count(*) from AFoneshop_topic")
    int queryTotal(Map<String, Object> map);
}
